<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>实施资料管理列表</title>
    <jsp:include page="/WEB-INF/view/commons/css.jsp" />
</head>
<body >
<div id="main-container" class="container-fluid">
	<input id="username" value="${username}" type="hidden">
    <form action="bizMaterialManage/dolist" method="post" name="searchForm" id="searchForm" role="form" class="form-horizontal">
        	<input id="type" name="type" value="${type}" type="hidden">
            <div class="form-group">
                    <label class="col-sm-1 control-label">经销商代码：</label>
                    <div class="col-md-4">
                                <input type="text" class="form-control" name="code" value="${entity.code}" placeholder="经销商代码">
                    </div>
                    <label class="col-sm-1 control-label">经销商名称：</label>
                    <div class="col-md-4">
                                <input type="text" class="form-control" name="name" value="${entity.name}" placeholder="经销商名称">
                    </div>
            </div>
            <div class="form-group">
                    <label class="col-sm-1 control-label">上传人：</label>
                    <div class="col-md-4">
                                <input type="text" class="form-control" name="uploadPerson" value="${entity.uploadPerson}" placeholder="上传人">
                    </div>
            </div>
        <div class="form-group">
            <label class="col-sm-1 control-label">关键字：</label>
            <div class="col-md-4">
                <div class="input-group">
                    <input type="text" class="form-control" name="keywords" value="${searchEntity.keywords}" placeholder="">
                    <div class="input-group-btn">
                        <button id="searchBtn" type="button" class="btn btn-sm btn-info"><i class="fa fa-search"></i> 搜索</button>
                    </div>
                </div>

            </div>
        </div>
    </form>
    <div class="row">
        <div class="col-md-10">
            <p>
               <button type="button" data-url="bizMaterialManage/add/${type}" class="btn btn-sm btn-success link_add" data-title="新增实施资料管理"><i class="fa fa-plus"></i> 新增</button>
            </p>
        </div>
    </div>

    <table id="table_data" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th class="center td-checkbox" width="5%">
                <label><input type="checkbox" class="check-all ace" data-tableid="table_data" /><span class="lbl"></span></label>
            </th>
            <th width="10%">经销商代码</th>
            <th width="10%">经销商名称</th>
            <th width="10%">上传人</th>
            <!-- <th width="10%">实施时间</th> -->
            <th width="10%">操作</th>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>
<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
</a>
<!-- script start -->
<jsp:include page="/WEB-INF/view/commons/js.jsp" />
<script type="text/javascript">
    $(document).ready(function(e) {
        var table = $("#table_data").dataTable({
            ajax: function(data, callback, settings){
                tableAjax($("#searchForm"),data, callback, settings);
            },
            //列表表头字段
            columns: [
                mainConfig.checkboxColumn,
                { "data": "code",name:"code",orderable:false  },
                { "data": "name",name:"name",orderable:false  },
                { "data": "uploadPerson",name:"upload_person",orderable:false  },
                /* { "data": "implTime",name:"impl_time" }, */
                { "data": "action",
                    "render": function ( data, type, row, meta ) {
                    	var A = "<a href='${res}/bizMaterialManage/download/"+ row.code +"/2;' >下载</a>";
                    	var B = "<a onclick=\"handlerDelete('" + row.code + "');\">删除</a>";
                    	if(row.uploadPerson == $("#username").val()){ 
                    		return A+"&nbsp;&nbsp;"+B; 
                    	}
                    	if(row.uploadPerson != $("#username").val()){ 
                    		return A;
                    	}
                    	return "";
                    },orderable:false 
               },
        ]
    }).api();

        //查询条件
        $("#searchForm").submit(function(){
            table.ajax.reload();
            return false;
        });
    });
    
    $('#imp_menu_btn').click(function(){
        openIframe({
            title:'新增实施资料管理',
            url:'bizMaterialManage/add',
            width:'600px',
            height:'450px'
        });

    });
    
    // 删除
    function handlerDelete(code){
        layer.confirm("确定要删除此记录吗?", function(index) {
            layer.close(index);
            $.ajax({
                url:  "/bizMaterialManage/delete",
                type: "post",
                data: {code:code,type:"2"},
                dataType: "json",
                success: function (data) {
                    if(data.success){
                    	 $('#searchForm').submit();
                    }else{
                        layer.alert(data.msg);
                    }
                }
            });
        });
    }
    
    // 实施材料下载
    function handlerShow(code){
    	 $.ajax({
             url: "${res}/bizMaterialManage/download",
             type: "post",
             data:{code : code,type :"2" },
             dataType: "json",
             success: function (data) {
                 if(data.success){
               	  
                 }else{
               	  layer.alert(data.msg);
                 }
             }
         });
    }
    
</script>
<!-- script end -->
</body>
</html>